<?php 
require_once '../config.php';
require_once('../functions.php'); ?>
<?php //$test =  strtotime('+3 hours', strtotime('2014/06/25 01:31:37'));
		$return = 1;
		if(!empty($_POST['username']) && !empty($_POST['password']))
		{
			$return = authenticate_user($_POST['username'],$_POST['password']);
			// login user
			if($return)
			{
				header('Location: http://'.$_SERVER['HTTP_HOST'] ."/admin/dashboard.php");
			}
		}
		//echo date('h:i:s a',$test);//exit;
		//echo date("Y/m/d h:i:s", strtotime("now")) . "<br>";
		//echo date("Y/m/d h:i:s", strtotime("+30 minutes"));
		//echo md5('BlueSky77'); 
?>
<html>
	<head>
		<title>Admin Panel</title>
		<link href="../css/bootstrap.min.css" type="text/css" rel="stylesheet" />
		<link href="../css/style.css" type="text/css" rel="stylesheet" />
		<style>
			#admin_wrapper {
				background: #fff;
				padding-top: 15px;
				padding-bottom: 15px;
				box-shadow: 0 1px 3px rgba(0,0,0,.13);
			}
			#admin_logo {
				margin-top:15%;
				margin-bottom: 20px;
			}
			#invalid_login {
				padding: 5px;
				margin-bottom: 10px;
			}
		</style>
	</head>
	<body style="background:#f1f1f1;">
		<div class="container">
			<div class="row">
				<div id="admin_logo" class="col-lg-2 col-md-2 col-sm-2 col-xs-6 col-lg-offset-5 col-md-offset-5 col-sm-offset-5 col-xs-offset-3">
					<img class="width-100" src="../img/logo.png">
				</div>
			</div>
			<div class="row">
				<div id="admin_wrapper" class="col-lg-4 col-md-6 col-sm-6 col-xs-12 col-lg-offset-4 col-md-offset-3 col-sm-offset-3">
					<?php if(isset($_GET['notloggedin']) && !empty($return)) { ?>
						<div id="invalid_login" class="bg-danger">Please login to continue.</div>
					<?php } ?>
					<?php if(empty($return)) { ?> 
						<div id="invalid_login" class="bg-danger">Username or Password wrong. Please try again.</div>
					<?php } ?>
					<form role="form" method="post" action="">
					  <div class="form-group">
					    <label for="username">Username</label>
					    <input type="text" class="form-control" id="username" placeholder="Enter Username" name="username">
					  </div>
					  <div class="form-group">
					    <label for="exampleInputPassword1">Password</label>
					    <input type="password" class="form-control" id="password" name="password" placeholder="Password">
					  </div>
					  <button type="submit" class="btn btn-default">Login</button>
					</form>
				</div>
			</div><!-- row ends -->
		</div><!-- container ends -->
	</body>
</html>